﻿using System;

namespace YArchitech.Plumbing
{
	public class SubstantialWaterColumnCalculationHelper
	{
		public double getSubstantialWaterColumn(double Hq, double f)
		{
			double num = Hq / (10.0 + f * Hq);
			double num2 = 0.0;
			double num3 = num;
			double num4 = (num2 + num3) / 2.0;
			int num5 = 0;
			do
			{
				num4 = (num2 + num3) / 2.0;
				double num6 = 1.19 + 80.0 * Math.Pow(0.01 * num4, 4.0);
				double num7 = num6 * num4 * 10.0 / (1.0 - f * num6 * num4) - Hq;
				if (Math.Abs(num7) < 0.0001)
				{
					break;
				}
				if (num7 > 0.0)
				{
					num3 = num4;
				}
				else
				{
					if (num7 >= 0.0)
					{
						break;
					}
					num2 = num4;
				}
				num5++;
			}
			while (num5 < 100);
			return num4;
		}

		public double getf(string str)
		{
			double result = 0.0;
			if (str == "13")
			{
				result = 0.0165;
			}
			else if (str == "16")
			{
				result = 0.0124;
			}
			else if (str == "19")
			{
				result = 0.0097;
			}
			return result;
		}

		public double getB(string str)
		{
			double result = 0.0;
			if (str == "13")
			{
				result = 0.346;
			}
			else if (str == "16")
			{
				result = 0.793;
			}
			else if (str == "19")
			{
				result = 1.577;
			}
			return result;
		}

		public double getFirePressure(double ad, double ld, double qxh, double b)
		{
			double num = ad * ld * qxh * qxh;
			double num2 = qxh * qxh / b;
			return num + num2;
		}

		public double gethq(double qxh, double b)
		{
			return qxh * qxh / b;
		}

		public static string getTxt(string str1, string str2)
		{
			string result = "";
			if (str1 == "50" && (str2 == "帆布" || str2 == "麻织"))
			{
				result = "0.01501";
			}
			else if (str1 == "50" && str2 == "衬胶")
			{
				result = "0.00677";
			}
			if (str1 == "65" && (str2 == "帆布" || str2 == "麻织"))
			{
				result = "0.00430";
			}
			else if (str1 == "65" && str2 == "衬胶")
			{
				result = "0.00172";
			}
			if (str1 == "80" && (str2 == "帆布" || str2 == "麻织"))
			{
				result = "0.00150";
			}
			else if (str1 == "80" && str2 == "衬胶")
			{
				result = "0.00075";
			}
			return result;
		}
	}
}
